package twitter.RequestHandler;

import java.util.concurrent.locks.ReentrantReadWriteLock;

import twitter.Server.ServerType;




/************************************************************
 * This class will generate the right type of HttpRequestHandler according
 * to the end message
 * @author fang
 *
 */
public class RequestHandlerAdapter {
	
	/***********************************************
	 * Class constructor
	 */
	public RequestHandlerAdapter()
	{
		
	}
	/***********************************************
	 * according to the end message generate the right type of HTTPRequestHandler
	 * @param end specify different types of HTTPRequestHandler
	 * @param rwl the read write lock
	 * @return HTTPRequestHandler
	 */
	public HTTPRequestHandler createHandler(String end,ReentrantReadWriteLock rwl)
	{
		HTTPRequestHandler handler=null;
		/* if(end.trim().equals("end"))
		{
			//handler=new BackendHttpRequestHandler(end,rwl);
			 handler=new PrimaryRequestHandler(end,rwl);
		}
		else if (end.trim().equals("connection"))
		{
			handler=new FrontendHttpRequestHandler(end,rwl);
		}
		else if(end.trim().equals("notification")) // receives a primary notification response
		{
			handler=new NoticeResponseHandler(end,rwl);
		}
		else if(end.trim().equals("registration"))
		{
			System.out.println("ServerRegistrationHandler");
			handler=new ServerRegistrationHandler(end, rwl);
		}
		*/
		return handler;
	}

}
